package bag;
//受查异常  编译时异常  需要自己声明 或者try catch
 class MyException extends Exception{
    public MyException(String s){
        super(s);
    }
}
//非受查异常  运行时爆出异常  不处理的话  会被jvm处理
class PasswordException1 extends RuntimeException{
    public PasswordException1(String s){
        super(s);
    }
}
public class TestDemo {
     public static void func(int x) throws MyException{
         //try{//或者也可以直接在上面声明
             if(x == 0){
                 System.out.println("异常");
                 throw new MyException("hh");
             }
         //}catch (MyException e){
           //  System.out.println("处理");
         //}

     }
     public static void func2(int x){
         if(x == 0){
             System.out.println("jasjd");
             throw new PasswordException1("haha");
         }
     }
    public static void main(String[] args) throws MyException {
        //func(0);
        try{
            func2(0);
        }catch (PasswordException1 e){
            e.printStackTrace();
        }

    }
}
